package com.micro.ai.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

/**
 * 菜单-权限关联Mapper
 * 
 * @author micro-ai
 * @since 0.0.1
 */
@Mapper
public interface MenuPermissionMapper extends BaseMapper<Object> {
    
    /**
     * 添加菜单-权限关联
     */
    @Insert("INSERT INTO menu_permissions (menu_id, permission_id) " +
            "VALUES (#{menuId}, #{permissionId})")
    int insert(@Param("menuId") String menuId, @Param("permissionId") String permissionId);
    
    /**
     * 删除菜单的所有权限关联
     */
    @Delete("DELETE FROM menu_permissions WHERE menu_id = #{menuId}")
    int deleteByMenuId(@Param("menuId") String menuId);
    
    /**
     * 删除权限的所有菜单关联
     */
    @Delete("DELETE FROM menu_permissions WHERE permission_id = #{permissionId}")
    int deleteByPermissionId(@Param("permissionId") String permissionId);
    
    /**
     * 删除指定的菜单-权限关联
     */
    @Delete("DELETE FROM menu_permissions WHERE menu_id = #{menuId} AND permission_id = #{permissionId}")
    int delete(@Param("menuId") String menuId, @Param("permissionId") String permissionId);
    
    /**
     * 检查菜单-权限关联是否存在
     */
    @Select("SELECT COUNT(*) FROM menu_permissions WHERE menu_id = #{menuId} AND permission_id = #{permissionId}")
    int exists(@Param("menuId") String menuId, @Param("permissionId") String permissionId);
}

